<!-- 添加好友 -->
<template>
  <div id="AddFriend">
    <!-- 头部 -->
    <Head title="添加好友" BackType1="true"></Head>
    <div id="AddFriendMain">
      <Search placeholder="根据平台账号查找好友" v-on:GlobalSearch="searchFriend" ref="search"></Search>
      <nothing v-show="hasInfo" nothing="请根据平台账号查找好友"></nothing>
      <nothing v-show="!hasInfo" nothing="该平台账号暂时没有用户"></nothing>
    </div>
  </div>
</template>

<script>
import Search from "@/components/Search";
import Head from "@/components/Head";
import nothing from "@/components/nothing";

export default {
  name: "AddFriend",
  data() {
    return {
      hasInfo: true
    };
  },
  components: {
    Search,
    Head,
    nothing
  },
  methods: {
    searchFriend() {
      let val = this.$refs.search.val;
      // console.log(val)
      this.$get(urlConfig.getFriendByPlatformId + val)
      .then(res => {
        if (res.data && res.data.length != 0) {
          this.$router.push({
            path: "/NewFriendInfo",
            query: {
              id: val,
              personStatus: 1
            }
          });
        }else{
          this.hasInfo = false; 
        }
      });
    }
  }
};
</script>

<style scoped lang='less'>
#AddFriend {
  font-size: 28px;
  #AddFriendMain {
    position: fixed;
    top: 88px;
    overflow: scroll;
    z-index: 10;
  }
}
</style>
